package cn.jiyun.controller;

//import cn.jiyun.common.AutoLogs;
import cn.jiyun.common.config.Result;
import cn.jiyun.entity.Yddqx;
import cn.jiyun.service.YddqxService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@RestController
@RequestMapping("/yddqx")
@CrossOrigin
public class YddqxController {
    @Autowired
    private YddqxService yddqxService;
    @RequestMapping("/findPage")
    public Result findPage(Integer pageNum, Integer pageSize, @RequestBody Yddqx yddqx){
        Page page = yddqxService.findPage(pageNum,pageSize,yddqx);
        return Result.ok(page);
    }

    @RequestMapping("/add")
//    @AutoLogs(value = "移动端权限添加操作", loggingtype  = 0)
    public Result add(@RequestBody Yddqx yddqx){
        if (yddqx.getId()!=null){
            yddqxService.updateById(yddqx);
        }else {
//            yddqx.setId(5);
            yddqx.setNum(0);
            yddqx.setCreateTime(new Date());
            yddqxService.save(yddqx);
        }
        return Result.ok("操作成功！");
    }

    @RequestMapping("deleteById")
//    @AutoLogs(value = "移动端权限删除操作", loggingtype  = 0)
    public Result deleteById(Integer id){
        yddqxService.removeById(id);
        return Result.ok("删除成功！");
    }

    @RequestMapping("findById")
    public Result findById(Integer id){
        Yddqx yddqx=yddqxService.getById(id);
        return Result.ok(yddqx);
    }

}
